<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>用户基本信息</title>
        <meta name="renderer" content="webkit">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="format-detection" content="telephone=no">
        <link rel="stylesheet" href="__PUBLIC__/X-admin/css/x-admin.css" media="all">
    </head>
    <body>
        <div class="x-nav">
            <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新"><i class="layui-icon" style="line-height:29px">ဂ</i> <i class="layui-icon" style="line-height:30px">刷新</i></a>
        </div>
	

        <div class="x-body">
			<div class="layui-tab layui-tab-card">
			  <ul class="layui-tab-title">
			    <li class="layui-this">基本信息</li>
          <li>个人头像</li>
			    <li>修改密码</li>
			  </ul>
			  <div class="layui-tab-content" style="height: 360px;">
			    <div class="layui-tab-item layui-show">
		            <table class="layui-table">
					  <colgroup>
					    <col width="150">
					    <col>
					  </colgroup>
					    <tr>
					      <th><img src="__PUBLIC__/photo/{$list['pic']}" ></th>
					      <th>{$list['name']}</th>
					    </tr> 
					    <tr>
					      <td>所在班级</td>
					      <td>{$list['class']}</td>
					    </tr>
					    <tr>
					      <td>所在小组</td>
					      <td>{$list['team']}</td>
					    </tr>
					    <tr>
					      <td>手机号码</td>
					      <td>{$list['phone']}</td>
					    </tr>
					    <tr>
					      <td>邮箱</td>
					      <td>{$list['email']}</td>
					    </tr>
					    <tr>
					      <td>所修专业</td>
					      <td>{$list['subject']}</td>
					    </tr>
					    <tr>
					      <td>用户状态</td>
					      <td>{$list['can_login']}</td>
					    </tr>
					</table>
			    </div>
			    <div class="layui-tab-item">
			    	<form action="__MODULE__/User/upload" method="post" enctype="multipart/form-data" >
			    		<input type="hidden" name="id" value="{$list['id']}" >
    						<table class="layui-table">
    					  <colgroup>
    					    <col width="50">
    					    <col>
    					  </colgroup>
    					    <tr>
    					      <th>原头像：</th>
    					      <th><img src="__PUBLIC__/photo/{$list['pic']}" ></th>
    					    </tr> 
    					    <tr>
    					      <td>上传头像</td>
    					      <td><input type="file" name="pic" ><br></td>
    					    </tr>
    					    <tr>
    					      <td colspan="2" ><button class="layui-btn" type="submit" lay-filter="formDemo">立即提交</button></td>
    					    </tr>
      					</table>
  			    		
  			    	</form>
			    </div>
          <div class="layui-tab-item">
            <form method="post" action="__MODULE__/User/updatePass" onsubmit="return demo()" class="layui-form layui-form-pane" >
            <!-- <form method="post" action="" onsubmit="return demo()" class="layui-form layui-form-pane" > -->
              <input type="hidden" name="id" value="{$list['id']}" >
                <div class="layui-form-item">
                  <label class="layui-form-label">初始密码：</label>
                  <div class="layui-input-inline">
                    <input type="password" id="old" name="oldpassword" required="" lay-verify="required" placeholder="请输入密码" autocomplete="off" class="layui-input">
                  </div>
                  <div id="oldpassid" class="layui-form-mid layui-word-aux"></div>
                </div>

                <div class="layui-form-item">
                  <label class="layui-form-label">新密码：</label>
                  <div class="layui-input-inline">
                    <input type="password" id="newpass" name="newpassword" required="" lay-verify="required" placeholder="请输入密码" autocomplete="off" class="layui-input">
                  </div>
                  <div id="newpassid" class="layui-form-mid layui-word-aux"> * 六到十八位的任意数字字母</div>
                </div>

                <div class="layui-form-item">
                  <label class="layui-form-label">确认密码：</label>
                  <div class="layui-input-inline">
                    <input type="password" id="newrepass" name="newrepassword" required="" lay-verify="required" placeholder="请输入密码" autocomplete="off" class="layui-input">
                  </div>
                  <div id="newrepassid" class="layui-form-mid layui-word-aux"> * 和新密码要一致</div>
                </div>

                <div class="layui-form-item">
                  <div class="layui-input-block">
                    <button class="layui-btn" lay-submit="" lay-filter="formpass">立即提交</button>
                  </div>
                </div>
                
              </form>
          </div>
			  </div>
			</div>
           

        </div>
        <script src="__PUBLIC__/X-admin/lib/layui/layui.js" charset="utf-8"></script>
        <script src="__PUBLIC__/X-admin/js/x-layui.js" charset="utf-8"></script>
        <script>

            layui.use(['element','laypage','layer','form'], function(){
                $ = layui.jquery;//jquery
              // laydate = layui.laydate;//日期插件
              lement = layui.element();//面包导航
              laypage = layui.laypage;//分页
              layer = layui.layer;//弹出层
              form = layui.form();
              

              oldpass = false;
              newpass = false;
              newrepass = false;
              $("#old").blur(function(){
                oldpassword = $("#old").val();
                $.post("__MODULE__/User/findpass",{oldpassword:oldpassword},function(data){
                  if(data=="成功"){
                    $("#oldpassid").text("通过");
                    oldpass = true;
                  }else{
                    $("#oldpassid").text("初始密码错误");
                    oldpass = false;
                  }

                });
                
              });

              $("#newpass").blur(function(){
                newpassword = $(this).val();
                  if(newpassword.match(/^[\w]{6,18}$/)){
                    $("#newpassid").text("通过");
                    newpass = true;

                  }else{
                    $("#newpassid").text("初始密码错误");
                    newpass = false;
                  }
                
              });

              $("#newrepass").blur(function(){
                newrepassword = $(this).val();
                newpassword = $("#newpass").val();
                  if(newpassword==newrepassword){
                    $("#newrepassid").text("通过");
                    newrepass = true;

                  }else{
                    $("#newrepassid").text("密码不一致");
                    newrepass = false;
                  }
                
              });

              
              
              //监听提交
              // if(oldpass && newpass && newrepass){
              //   form.on('submit(formpass)', function(data){

              //     newpassword = $("#newpass").val();
              //       $.post('__MODULE__/User/updatePass',{newpassword:newpassword},function(data){
              //         if(data!="成功"){
              //             alert('数据修改失败');
              //             return false;
              //         }else{
              //           layer.msg('修改成功', {icon: 1,time:2000},function(){
              //             location.replace(location.href);
              //           });
              //           return false;
                        
              //         }
              //       });
              //   });
              //   return false;
              // }

              
            });

            function demo(){
                  if(oldpass & newpass & newrepass){
                      return true;
                  }else{
                      return false;
                  }
              }

            </script>
    </body>
</html>